<?php
/**
 * 抽象工厂模式
 * This file is part of pattern.
 * Author: tangzhou
 * Date: 2016/8/26
 * Time: 13:50
 * File: AbstractFactory.php
 */

/**
 * 吃的
 * Interface EatFood
 */
interface EatFood
{
    function eat();
}

/**
 * 喝的
 * Interface DrinkFood
 */
interface DrinkFood
{
    function drink();
}

class EatRouFood implements EatFood
{
    function eat()
    {
        echo "吃肉";
    }
}

class EatCaiFood implements EatFood
{
    function eat()
    {
        echo "吃菜";
    }
}

class DrinkBearFood implements DrinkFood
{
    function drink()
    {
        echo "喝啤酒";
    }
}

class DrinkColaFood implements DrinkFood
{
    function drink()
    {
        echo "喝可乐";
    }
}

interface AbstractFactory
{
    function eat();
    function drink();
}

/**
 * 创建A套餐
 * Class AFactory
 */
class AFactory implements AbstractFactory
{
    function eat()
    {
        return new EatCaiFood();
    }
    function drink()
    {
        return new DrinkColaFood();
    }
}

/**
 * 创建B套餐
 * Class BFactory
 */
class BFactory implements AbstractFactory
{
    function eat()
    {
        return new EatRouFood();
    }
    function drink()
    {
        return new DrinkColaFood();
    }
}